<?php
class M_categories extends CI_Model {

    function __construct() {
        parent::__construct();
        $this->load->database();
    }

    function getallcategories() {
        $sql = $this->db->get('categories');
        $result = $sql->result();
        return $result;
    }

    function gettitle() {
        $results = $this->db->get_where('categories', array('category_id' => category_id));
        $result = $results->result();
        $result = $results[0];
        return $result;
    }

    function getcategoryid($title) {
        $item = 0;
        $query = $this->db->get_where('categories', array('title' => $title));
        foreach ($query->result() as $row) {
            $item = $row->category_id;
        }

        return $item;
        //put your code here
    }
    function gettulevel(){
        $results= $this->db->get_where('categories',array('level'=> 3))->result();
        //$result=$results->result();
        //$result=$results[0];
        return $results;
        
    }
    function getcategoryparent(){
        $results= $this->db->get_where('categories', array('type'=>0))->result();
       // $results= $this->db->get_where('categories',array('type'=> ))->result();
        //$result=$results->result();
        //$result=$results[0];
       return $results;
    }
    function getcategorycon($tyle){
        $results = $this->db->get_where('categories',array ('type'=>$tyle))->result();
         return $results;
    }
}

?>
